package com.bao.Servlet;


import com.alibaba.fastjson.JSON;
import com.bao.Emtity.User;
import com.bao.Emtity.agency;
import com.bao.Service.AgencyService;
import com.bao.Service.UserService;
import com.bao.ServiceImpl.AgencyServiceImpl;
import com.bao.ServiceImpl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * Created by TangBaoshan on 2018/8/6.
 */
@WebServlet(name = "Findagency0Servlet")
public class Findagency0Servlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
//      //  放入
//        String name="张山";
//        request.getSession().setAttribute("name",name);
//        //取出
//         String u=(String) request.getSession().getAttribute("name");
        UserService se = new UserServiceImpl();
        AgencyService ser = new AgencyServiceImpl();
        agency a = new agency();
        String name = request.getParameter("uname");
        List<User> user1 = se.findTypeUser(name);
        String user = JSON.toJSONString(user1);
        out.print(user);
        out.flush();
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
             doPost(request,response);
    }
}